import javax.swing.plaf.synth.SynthToolTipUI;

/**
 * Created with IntelliJ IDEA
 * Description:类 初学习
 * User:22954
 * Date:2024-01-06
 * Time:1:14
 */
public class Student{
    public String name;
    public int age;
    public String sex;

    public Student(){
        this("wangwu",20);//this()为调用其他构造方法，this()必须在构造方法的第一行
        System.out.println("haha");
        /*this("wangwu",20);*/
    }

    public String getName() {
        return name;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Student(String name, int age){
        /*this();*/ //this()不能形成循环
        this.name=name;
        this.age=age;
        System.out.println("hehe");
    }
    public void setData(String name,int age,String sex){
        this.name=name;//this.调用成员变量
        this.age=age;
        this.sex=sex;
    }
    public void printData(){
        System.out.println("名字:"+name+" 性别:"+sex+" 年龄:"+age);
    }
    public void fun(){
        this.printData();//this.调用成员方法
    }

    public static void main(String[] args) {
        Student student1=new Student();
        Student student2=new Student("zhangsan",18);

/*        student1.setData("zhangsan",18,"male");
        student1.fun();*/
    }
}

